<?php
	include_once 'isLogin.php';
	$table='user_oversea_experience';			//会员海外经历表
	$continent_table='continent';				//洲表
	$userc=new user();
	$user_id=$_GET['id'];		//会员id
	$eid=$_GET['eid'];			//教育经历id

	//海外经历删除
	if($_GET['action']=='del'){
		$res=$commonc->del($table,$eid.',');
	}

	//批量删除
	if($_GET['action']=='delMany'){
		$id=$_POST['id'];
		$res=$commonc->del($table,$id);
		echo $res;
		exit();
	}

	//添加海外经历
	if($_POST['submit']!=''){
		$arr=array(
			'user_id'=>$user_id,'continent_id'=>$_POST['continent_id']
			,'create_time'=>time(),'school'=>$_POST['school']
			,'profession'=>$_POST['profession'],'country_id'=>$_POST['country_id']
			,'entrance_time'=>strtotime($_POST['entrance_time'])
			,'granduate_time'=>strtotime($_POST['granduate_time'])
			,'city'=>$_POST['city']
			);
		$res=$commonc->insert($table,$arr);
		$id=$commonc->insert_id();
	}

	//七大洲
	$sql=$continent_table.' order by id asc';
	$continents=$commonc->getList($sql);
	$smarty->assign('continents',$continents['result']);
		
	//会员教育经历信息					
	$where=' and us.user_id="'.$user_id.'" order by us.id desc';
	$key='us.*,c.country,from_unixtime(us.entrance_time,"%Y-%m-%d") as entranceTime
		,from_unixtime(us.granduate_time,"%Y-%m-%d") as granduateTime';
	$overseas=$userc->overseaList($where,$key);
	if(is_array($overseas['result'])){
		foreach($overseas['result'] as $k=>$v){
			if(is_array($continents['result'])){
				foreach($continents['result'] as $key=>$val){
					if($v['continent_id']==$val['id']){
						$overseas['result'][$k]['continent']=$val['continent'];
					}	
				}
			}
		}
	}
	$smarty->assign('overseas',$overseas['result']);

	
	$smarty->display("user_oversea.html");
?>